<?php
require_once dirname(dirname(__FILE__)) . '/shared/config/config.php';
require_once DOCUMENT_ROOT . DIR_SHARED_API . 'api_tickets.php';
$number = filter_input(INPUT_POST, "number");
?>

<script type="text/javascript">
    $(document).ready(function() {
        $('.ui .item').on('click', function() {
            $('.ui .item').removeClass('active');
            $(this).addClass('active');
        });
        $('.ui.dropdown').dropdown({
            on: 'hover'
        });
    });
</script>
    <form name="form_add_data" id="form_add_data" method="POST" action="?" enctype="multipart/form-data">
<?php
for ($index = 0; $index < $number; $index++) {?>
    <div class="ui form segment form-background">
        <input type="hidden" name="index<?php echo $index; ?>" value="1" />

                            <div class="field">
                                <label for="Name">Name <span class="required">*</span></label>
                                <input name="txt_name<?php echo $index; ?>" type="text" value="" placeholder="e.g: ticket 1" />
                            </div>
                            
                            <div class="field">
                                <label for="Status">Movie <span class="required">*</span></label>
                                <div class="ui selection dropdown">
                                    <?php $movie = api_tickets::get_default_movie(); ?>
                                    <input type="hidden" name="ddl_movie<?php echo $index; ?>" value="<?php echo $movie; ?>">
                                    <div class="text"><?php echo $movie; ?></div>
                                    <i class="dropdown icon"></i>
                                    <div class="menu ui transition hidden">
                                      <?php 
                                        $list = api_tickets::get_all_movies();
                                        if (!empty($list) && count($list) > 0) {
                                            foreach ($list as $item) {?>
                                                <div class="item"><?php echo $item['title']; ?></div>
                                      <?php
                                            } 
                                        }?>
                                    </div>
                                  </div>
                            </div>
                            
                            <div class="field">
                                <label for="Status">Cinema <span class="required">*</span></label>
                                <div class="ui selection dropdown">
                                    <?php $cinema = api_tickets::get_default_cinema(); ?>
                                    <input type="hidden" name="ddl_cinema<?php echo $index; ?>" value="<?php echo $cinema; ?>">
                                    <div class="text"><?php echo $cinema; ?></div>
                                    <i class="dropdown icon"></i>
                                    <div class="menu ui transition hidden">
                                      <?php 
                                        $list = api_tickets::get_all_cinemas();
                                        if (!empty($list) && count($list) > 0) {
                                            foreach ($list as $item) {?>
                                                <div class="item"><?php echo $item['name']; ?></div>
                                      <?php
                                            } 
                                        }?>
                                    </div>
                                  </div>
                            </div>
                            
                            <div class="field">
                                <script type="text/javascript">
                                    $(document).ready(function() {
                                        jQuery('#dtp_show_date<?php echo $index; ?>').datetimepicker({
                                            timepicker:false,
                                            format:'d/m/Y'
                                           });
                                    });
                                </script>
                                <label for="Status">Date <span class="required">*</span></label>
                                <input name="dtp_show_date<?php echo $index; ?>" value="" type="text" id="dtp_show_date<?php echo $index; ?>" placeholder="e.g: 25/05/2014" style="width:200px;">
                            </div>
                            
                            <div class="field">
                                <script type="text/javascript">
                                    $(document).ready(function() {
                                        jQuery('#dtp_time_start<?php echo $index; ?>').datetimepicker({
                                            datepicker:false,
//                                            allowTimes:[
//                                             '12:00', '13:00', '15:00', 
//                                             '17:00', '17:05', '17:20', '19:00', '20:00'
//                                            ],
                                            format:'H:i'
                                           });
                                    });
                                </script>
                                <label for="Status">Time Start <span class="required">*</span></label>
                                <input name="dtp_time_start<?php echo $index; ?>" value="" type="text" id="dtp_time_start<?php echo $index; ?>" placeholder="e.g: 21:30" style="width:200px;">
                            </div>
                            
                            <div class="field">
                                <label for="Name">Duration (min) <span class="required">*</span></label>
                                <input name="txt_duration<?php echo $index; ?>" value="" type="text" placeholder="e.g: 60 (min)" />
                            </div>

                            <div class="field">
                                <label for="Name">Price (USD) <span class="required">*</span></label>
                                <input name="txt_price<?php echo $index; ?>" value="" type="text" placeholder="e.g: 50 (USD)" />
                            </div>
    </div>
    <br/>
<?php
}
?>
    <div class="ui form segment form-background">
        <input type="hidden" name="Action" value="">
        <div class="ui buttons">
            <a href="?"><div class="ui  button">Cancel</div></a>
            <div class="or"></div>
            <div id="action-add-button" class="ui orange button" onclick="submit_add_data();">Add All</div>
        </div>
    </div>
    
    </form>
